def run(params:list[str]):
    import matplotlib.pyplot as plt

    # Though the following import is not directly being used, it is required
    # for 3D projection to work with matplotlib < 3.2
    import mpl_toolkits.mplot3d  # noqa: F401
    import numpy as np

    from sklearn import datasets
    from sklearn.cluster import KMeans

    ### 2.1.1 Kmeans聚类2维空间可视化 - 2个特征（跟根据情况自行选择）

    from ApiBase import apiBase
    try:
        data=apiBase.argv_json(params,1,{"0.1,0.2":"0.1","0.3,0.4":"0.2","0.4,0.5":"0.2","0.6,0.7":"0.1","0.8,0.9":"0.1"})
        #apiBase.log("param1="+str(data))
        X_digits=[]
        y_digits=[]
        for key in data.keys():
            numbers = [float(num) for num in key.split(',')]
            X_digits.append(numbers)
            val=data[key]
            y_digits.append(val)

        #加载iris数据集
        # iris = datasets.load_iris()
        # X = iris.data
        # y = iris.target
        # print(X)
        # print(y)

        # 初始化K均值模型
        kmeans = KMeans(n_clusters=3, random_state=0)

        # 训练模型
        kmeans.fit(X_digits)

        # 获取聚类结果
        labels = kmeans.labels_
        return labels        
    except Exception as e:
        return f"function error:{e}"